package de.windeln.marketing.promotion;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class PromotionController {

	@Resource(name = "promotionService")
	private PromotionService promotionService;

	@RequestMapping(value = "/promotions*", method = RequestMethod.GET, produces = "application/json")
	public @ResponseBody Map fetchAllPromotions() {
		Map<String, Object> container = new HashMap();
		container.put("aaData", promotionService.fetchAllPromotions());
		return container;
	}
	
	@RequestMapping(value = "/insertpromotion*", method = RequestMethod.GET, produces = "application/json")
	public @ResponseBody Map createNewPromotion() {
		Map<String, Object> container = new HashMap();
		container.put("aaData", promotionService.insertNewPromotion());
		return container;
	}
}
